package com.example.spring.demo.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.spring.demo.entity.Goods;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface GoodsMapper extends BaseMapper<Goods> {
    //查询我的订单
    @Select("""
select g.*, gr.order_id, gr.create_time as sell_time, gr.price
from goods_order as gr
left join goods as g
on g.goods_id = gr.goods_id
where gr.order_user = #{userId}
""")
    IPage<Goods> getMyOrder(IPage<Goods> page, @Param("userId") Long userId);

    //查询出售订单
    @Select("""
select g.*, gr.order_id, gr.create_time as sell_time, gr.price
from goods_order as gr
left join goods as g
on g.goods_id = gr.goods_id
where g.user_id = #{userId}
""")
    IPage<Goods> getSellOrder(IPage<Goods> page, @Param("userId") Long userId);
}
